<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateUsersTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('users', function (Blueprint $table) {
            $table->bigIncrements('id')->unique()->comment('主键ID');
            $table->string('true_name')->nullable()->comment('真实姓名')->index('true_name_index');
            $table->string('nickname')->nullable()->comment('微信昵称')->index('nickname_index');
            $table->string('phone')->nullable()->comment('电话')->index('phone');
            $table->string('country_code')->nullable()->comment('手机区号')->index('country_code_index');
            $table->string('unionid')->nullable()->comment('同一公众平台下绑定不同应用（App、公众号、小程序）的用户唯一ID')->index('unionid_index');
            $table->tinyInteger('gender')->nullable()->comment('1是男，2是女，0未知')->index('gender_index');
            $table->string('avatarUrl')->nullable()->comment('头像URL地址')->index('avatarUrl_index');
            $table->string('country')->nullable()->comment('用户所在国家')->index('country_index');
            $table->string('province')->nullable()->comment('用户所在省份');
            $table->string('city')->nullable()->comment('用户所属在城市');
            $table->string('openid')->nullable()->unique()->comment('小程序的openid');
            $table->string('session_key')->nullable()->comment('用来解密微信提供的加密数据');
            $table->string('language')->nullable()->comment('语言');
            $table->timestamps();
        });

        DB::statement("ALTER TABLE `users` comment '微信小程序用户信息表'");
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('users');
    }
}
